using System.Windows.Controls;
using NUnit.Framework;
using ShadeTree.Binding.Drivers;

namespace ShadeTree.Binding.Tests.Drivers
{
    [TestFixture]
    public class WPFControlDriverTester
    {
        [Test]
        public void FireClick_does_indeed_fire_click()
        {
            bool iWasCalled = false;
            
            Button button = new Button();
            button.Click += delegate { iWasCalled = true; };
            WPFControlDriver driver = new WPFControlDriver(button);
            driver.Click();

            iWasCalled.ShouldBeTrue();
        }        

        [Test]
        public void FireLostFocus_does_indeed_fire_LostFocus()
        {
            bool iWasCalled = false;

            Button button = new Button();
            
            WPFControlDriver driver = new WPFControlDriver(button);
            driver.OnLostFocus(()=> iWasCalled = true);

            button.LostFocus += delegate{ iWasCalled = true;};

            driver.FireLostFocus();

            iWasCalled.ShouldBeTrue();            
        }

        [Test]
        public void SetAndRetrieveToolTips()
        {
            Button button = new Button();

            WPFControlDriver driver = new WPFControlDriver(button);

            driver.ToolTipText = "something";

            driver.ToolTipText.ShouldEqual("something");
        }
    }
}